<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>白条记录</title>
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
    <style type="text/css">
        .detail {
            padding-right: 20px!important;
        }

        h5 {
            color: #0062CC;
        }
    </style>
</head>

<body>
    <div class="mui-content">
        <ul class="mui-table-view mui-table-view-chevron" id="stockDetailContent">
			<script type="text/template" id="items">
			<li class="mui-table-view-cell detail">
				<div class="mui-table">
	                <div class="mui-table-cell mui-col-xs-4">
	                    <h5 class="mui-ellipsis">SGMW ID：</h5>
	                </div>
	                <div class="mui-table-cell mui-col-xs-8 mui-text-right">
	                    <span class="mui-h5">{{datas.itemnum}}</span>
	                </div>
	            </div>
			</li>
			<li class="mui-table-view-cell detail">
				<div class="mui-table">
	                <div class="mui-table-cell mui-col-xs-4">
	                    <h5 class="mui-ellipsis">仓库：</h5>
	                </div>
	                <div class="mui-table-cell mui-col-xs-8 mui-text-right">
	                    <span class="mui-h5">{{datas.location}}</span>
	                </div>
	            </div>
			</li>
			<li class="mui-table-view-cell detail">
				<div class="mui-table">
	                <div class="mui-table-cell mui-col-xs-4">
	                    <h5 class="mui-ellipsis">库存地址：</h5>
	                </div>
	                <div class="mui-table-cell mui-col-xs-8 mui-text-right">
	                    <span class="mui-h5">{{datas.binnum}}</span>
	                </div>
	            </div>
			</li>
			<li class="mui-table-view-cell detail">
				<div class="mui-table">
	                <div class="mui-table-cell mui-col-xs-4">
	                    <h5 class="mui-ellipsis">描述：</h5>
	                </div>
	                <div class="mui-table-cell mui-col-xs-8 mui-text-right">
	                    <span class="mui-h5">{{datas.description}}</span>
	                </div>
	            </div>
			</li>
			<li class="mui-table-view-cell detail">
				<div class="mui-table">
	                <div class="mui-table-cell mui-col-xs-4">
	                    <h5 class="mui-ellipsis">规格：</h5>
	                </div>
	                <div class="mui-table-cell mui-col-xs-8 mui-text-right">
	                    <span class="mui-h5">{{datas.cSpcifications}}</span>
	                </div>
	            </div>
			</li>
			</script>
		</ul>
        <div class="mui-segmented-control mui-segmented-control-inverted mui-segmented-control-primary segmentedControl type_list_spair">
            <a class="mui-control-item" tapmode onclick="ChMonth(1)">近一个月</a>
            <a class="mui-control-item" tapmode onclick="ChMonth(12)">近一年</a>
            <a class="mui-control-item" tapmode onclick="ChMonth('')">全部</a>
        </div>
        <div class="mui-content" id="LocationContent">
            <script type="text/template" id="itemslist">
                {{each datas as item i}}
                <div class="mui-card">
                    <ul class="mui-table-view mui-table-view-chevron">
                        <li class="mui-table-view-cell mui-collapse">
                            <a class="mui-navigate-right" href="#">交易类型：{{item.transtype}}
                							<span class="mui-badge mui-badge-inverted">{{item.transdate}}</span>
                						</a>
                            <ul class="mui-table-view mui-table-view-chevron">
                                <li class="mui-table-view-cell">数量：{{item.quantity}}</li>
                                <li class="mui-table-view-cell">单价：{{item.unitcost}}</li>
                                <li class="mui-table-view-cell">金额：{{item.linecost}}</li>
                                <li class="mui-table-view-cell">录入人：{{item.enterbyName}}</li>
                                <li class="mui-table-view-cell">工单：{{item.refwo}}</li>
                                <li class="mui-table-view-cell">位置：{{item.location}}</li>
                            </ul>
                        </li>
                    </ul>
                    <div class="mui-card-footer">
            					<a class="mui-card-link" tapmode onclick="openBlankRegister('{{item.matusetransid}}')">白条登记</a>
            					<a class="mui-card-link"></a>
            					<a class="mui-card-link"></a>
            				</div>
                </div>
                {{/each}}
            </script>
        </div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script src="../script/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/common.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/template.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    var page = 1;
    var loadEnd = false;
    var LocationId = '',
        locationName = '',
        // Location = '',
        chmonths = 1;
    apiready = function() {
        onLoadData(page, false);
        onLoadDetail()
        scrollToBottomHandler(function() {
            if (!loadEnd) { // 没有结束时继续加载
                page++;
                onLoadData(page, true);
            } else { // 告诉到底了
                EndToast('到底了');
            }
        })
        Refresh(function() {
            loadEnd = false;
            page = 1;
            onLoadData(page, false);
        });
		api.addEventListener({
	        name: 'refersh'
	    }, function(ret, err) {
	      if(ret.value.isrefersh == 'yes'){
	        onLoadData(1,false);
	      }
	    });
        api.addEventListener({
            name: 'navitembtn'
        }, function(ret, err) {
            if (ret.type == 'right') {
                // console.log($api.dom("input[type='radio']:checked"))
                api.sendEvent({
                    name: 'LocactionId',
                    extra: {
                        locationid: LocationId,
                        locationName: locationName,
                        // Location: Location
                    }
                });
                setTimeout(function() {
                    api.closeWin();
                }, 100)
            }
        })
    }

    function onLoadData(page, load) {
        ajaxrd("querBlankNoteList", {
            months:chmonths,
            itemnum:api.pageParam.itemid,
            pageNo: page,
            pageSize: 10
        }, function(ret, err) {
            api.refreshHeaderLoadDone();
            AddData('itemslist', 'LocationContent', ret.list, load);
            if (ret.list.length < 10) {
                loadEnd = true
            }
        })
    }
    function onLoadDetail() {
        ajaxrd("queryItemDetail", {
			inventoryid: api.pageParam.inventoryid || '',
			itemnum: api.pageParam.itemnum || '',
			binnum: api.pageParam.binnum ||''
		}, function(ret, err) {
			AddData('items','stockDetailContent',ret, false);
		})
    }
    var ChMonth = function(id) {
        chmonths = id
        loadEnd = false;
        page = 1;
        onLoadData(page, false);
    }
    function openBlankRegister (id) {
      openWin('stock_blank_register','白条登记',{
            background: '#6098de',
            color: '#fff',
            rightButtons:[{
              iconPath:"widget://image/save-icon.png"
            }]
        },{
          matusetransid:id,
          itemnum: api.pageParam.itemnum
        })
    }
</script>

</html>
